﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Weblications.Sango.Battle;
using Pixysoft.Framework.Configurations;
using Pixysoft.Framework.Verifications;

namespace Pixysoft.Weblications.Sango.Dao
{
    class LogPvxBattleVideoDao
    {
        public static Entities.Log_Pvxbattlevideo createLog(long sectionSerialcode, long stageSerialcode, PvxBattleHistory history)
        {
            Entities.Log_Pvxbattlevideo orm = Entities.Local.Log_Pvxbattlevideo;
            orm.Logcode = PkHelper.LogCode();
            orm.Sectionserialcode = sectionSerialcode;
            orm.Stageserialcode = stageSerialcode;
            orm.Videodata = StringCoder.StringToByte(XmlManager.Serialize(history).Serialize());
            return orm;
        }

        public static Entities.Log_Pvxbattlevideo getLog(string videocode)
        {
            Entities.Log_Pvxbattlevideo orm = SettingHelper.GetNoebe().EntityNoebeCommand.SelectByPk<Entities.Log_Pvxbattlevideo>(videocode);

            if (orm == null)
                throw Exceptions.VerificationFailedException(videocode);

            return orm;
        }
    }
}
